﻿using Leo.Common.MQ;
using RabbitMQ.Client;

namespace Leo.Common.RabbitMQ
{
    //[NullableContext(1)]
    //[Nullable(0)]
    internal class RecvMsgInfo
    { 
        public RecvMsgInfo(ulong deliveryTag, IBasicProperties properties,/* [Nullable(0)] */ReadOnlyMemory<byte> body, IModel sender, string exchange, string routingKey, string data)
        {
            this.DeliveryTag = deliveryTag;
            this.Properties = properties;
            this.Body = body;
            this.Sender = sender;
            this.Exchange = exchange;
            this.RoutingKey = routingKey;
            this.Data = data;
        }

      
        public ulong DeliveryTag { get; set; }
         
        public IBasicProperties Properties { get; set; }
         
        //[Nullable(0)]
        public ReadOnlyMemory<byte> Body { /*[NullableContext(0)] */get; /*[NullableContext(0)] */set; }
         
        public IModel Sender { get; set; }
         
        public string Exchange { get; set; }
         
        public string RoutingKey { get; set; }
         
        public string Data { get; set; }
         
        public MessageData AsReceivedMessage()
        {
            return new MessageData
            {
                QueueType = MessageQueueType.RabbitMQ,
                MessageType = this.Properties.Type,
                MessageId = this.Properties.MessageId,
                CorrelationId = this.Properties.CorrelationId,
                Content = this.Data
            };
        }
    }
}
